export function formatDate(numb, format = '/') {
  const time = new Date((numb - 1) * 24 * 3600000 + 1)
  time.setYear(time.getFullYear() - 70)
  const year = time.getFullYear() + ''
  const month = time.getMonth() + 1 + ''
  const date = time.getDate() - 1 + ''
  if (format && format.length === 1) {
    return year + format + (month < 10 ? '0' + month : month) + format + (date < 10 ? '0' + date : date)
  }
  return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date)
}
export function transExcelHander(results) {
  const userRelations = {
    '入职日期': 'timeOfEntry',
    '手机号': 'mobile',
    '姓名': 'username',
    '转正日期': 'correctionTime',
    '工号': 'workNumber'
  }
  const newArr = results.map(item => {
    const userInfo = {}
    for (const key in item) {
      const newKey = userRelations[key]
      userInfo[newKey] = item[key]
      if (['correctionTime', 'timeOfEntry'].includes(newKey)) {
        // 需要对key对应的value做时间处理
        // 严格来讲需要使用与excel插件配套的时间处理函数 处理成标准的时间Date格式
        // 后端接口才能识别
        userInfo[newKey] = new Date(formatDate(item[key]))
      }
    }
    return userInfo
  })
  //   console.log(newArr)
  return newArr
}
